<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<title>simConvexDecompose</title>
<link rel="stylesheet" type="text/css" href="../../style.css">
</head>

<body>

<div align="center">
<table class=allEncompassingTable >
 <tr>
  <td >
<p><a href="../../index.html" TARGET="_top"><img src="../images/homeImg.png"></a></p>

<h1>Regular API function</h1>
<h3 class=subsectionBar><a name="simConvexDecompose" id="simConvexDecompose"></a>simConvexDecompose / sim.convexDecompose </h3>
<table class=apiTable>
<tr class=apiTableTr> 
<td class=apiTableLeftDescr>
Description 
</td> 
<td class=apiTableRightDescr>Calculates the <a href="../convexDecomposition.htm">convex decomposition</a> of a <a href="../shapes.htm">shape</a> using the HACD or V-HACD algorithms. See also <a href="simGetQHull.htm">sim.getQHull</a>, <a href="simGetDecimatedMesh.htm">sim.getDecimatedMesh</a>, <a href="simUngroupShape.htm">sim.ungroupShape</a> and <a href="simComputeMassAndInertia.htm">sim.computeMassAndInertia</a>.</td>
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCSyn>
C synopsis
</td> 
<td class=apiTableRightCSyn>simInt simConvexDecompose(simInt shapeHandle,simInt options,const simInt* intParams,const simFloat* floatParams)</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCParam>C parameters</td> 
<td class=apiTableRightCParam>
<div><strong>shapeHandle</strong>: handle of the shape to operate on</div>
<div><strong>options</strong>: bit-coded:</div>
<div class=tab>bit0 set (1): the specified shape will be morphed into its convex decomposition. Otherwise, the convex decomposition will smply be added to the scene</div>
<div class=tab>bit1 set (2): specified convex decomposition parameters will be displayed in a dialog, allowing the user to modify them.</div>
<div class=tab>bit2 set (4): same convex decomposition parameters will be used as a previous call to this function. Only when this bit is set can the convex decomposition parameters be omitted.</div>
<div class=tab>bit3 set (8): HACD: extra points will be added when computing the concavity</div>
<div class=tab>bit4 set (16): HACD: faces points will be added when computing the concavity</div>
<div class=tab>bit5 set (32): each individual mesh of a compound shape will be handled on its own during decomposition, otherwise the compound shape is considered as a single mesh</div>
<div class=tab>bit6  (64): reserved. Do not set.</div>
<div class=tab>bit7 set (128): the V-HACD algorithm ○will be used. If not set, the HACD algorithm will be used.</div>
<div class=tab>bit8 set (256): V-HACD: pca is enabled (default is disabled).</div>
<div class=tab>bit9 set (512): V-HACD: tetrahedron-based approximate convex decomposition. If not set, then the voxel-based approximate convex decomposition will be used (default).</div>

<div><strong>intParams</strong>: 10 int values:</div>
<div class=tab>intParams[0]: HACD: the minimum number of clusters to be generated (e.g. 1)</div>
<div class=tab>intParams[1]: HACD: the targeted number of triangles of the decimated mesh (e.g. 500)</div>
<div class=tab>intParams[2]: HACD: the maximum number of vertices for each generated convex hull (e.g. 100)</div>
<div class=tab>intParams[3]: HACD: the maximum number of iterations. Use 0 for the default value (i.e. 4).</div>
<div class=tab>intParams[4]: reserved. Set to 0.</div>
<div class=tab>intParams[5]: V-HACD: resolution (10000-64000000, 100000 is default).</div>
<div class=tab>intParams[6]: V-HACD: depth (1-32, 20 is default).</div>
<div class=tab>intParams[7]: V-HACD: plane downsampling (1-16, 4 is default).</div>
<div class=tab>intParams[8]: V-HACD: convex hull downsampling (1-16, 4 is default).</div>
<div class=tab>intParams[9]: V-HACD: max. number of vertices per convex hull (4-1024, 64 is default).</div>

<div><strong>floatParams</strong>: 10 float values:</div>
<div class=tab>floatParams[0]: HACD: the maximum allowed concavity (e.g. 100.0)</div>
<div class=tab>floatParams[1]: HACD: the maximum allowed distance to get convex clusters connected (e.g. 30)</div>
<div class=tab>floatParams[2]: HACD: the threshold to detect small clusters. The threshold is expressed as a percentage of the total mesh surface (e.g. 0.25)</div>
<div class=tab>floatParams[3]: reserved. Set to 0.0</div>
<div class=tab>floatParams[4]: reserved. Set to 0.0</div>
<div class=tab>floatParams[5]: V-HACD: concavity (0.0-1.0, 0.0025 is default).</div>
<div class=tab>floatParams[6]: V-HACD: alpha (0.0-1.0, 0.05 is default).</div>
<div class=tab>floatParams[7]: V-HACD: beta (0.0-1.0, 0.05 is default).</div>
<div class=tab>floatParams[8]: V-HACD: gamma (0.0-1.0, 0.00125 is default).</div>
<div class=tab>floatParams[9]: V-HACD: min. volume per convex hull (0.0-0.01, 0.0001 is default).</div>

</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCRet>
C return value
</td> 
<td class=apiTableRightCRet>
<div>-1 if operation was not successful. Otherwise the handle of the new shape, or the handle of the original shape when morphing.<br>
</div>
</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLSyn>
Lua synopsis
</td> 
<td class=apiTableRightLSyn>int shapeHandle=sim.convexDecompose(int shapeHandle,int options,table[4] intParams,table[3] floatParams)</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLParam>Lua parameters</td> 
<td class=apiTableRightLParam>
<div>Similar to the C-function counterpart</div>
</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLRet>
Lua return values
</td> 
<td class=apiTableRightLRet>
<div>Similar to the C-function counterpart</div>
</td> 
</tr> 
</table> 


<br>
</td>
</tr>
</table>
</div>
</body>
</html>
